package StudyCode.summary.textfile;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadTwoDigitHexadecimalSequences {

	public static void main(String[] arguments) {
		main();
	}

	public static void main() {
		FileReader file;
		try {
			file = new FileReader("E:/Copy/hexfile.txt");
			BufferedReader buff = new BufferedReader(file);

			boolean eof = false;
			while (!eof) {
				String line = buff.readLine();
				if (line == null) {
					eof = true;
				} else {
					readLine(line);
				}
			}
			buff.close();
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}

	private static void readLine(String code) {
		try {
			for (int j = 0; j + 1 < code.length(); j += 2) {
				String sub = code.substring(j, j + 2);
				int num = Integer.parseInt(sub, 16);
				if (num == 255) {
					return;
				}
				System.out.print(num + " ");
			}
		} finally {
			System.out.println("**");
		}
	}

}
